<?php
/**
 * 淘宝信用图标! (全静态方法)
 *
 * @filesource TaobaoUserCredit.php
 * @package LinkMiner 
 * @subpackage Taoshow
 * @version $id: 0.1, utf8, $
 * @author LD King <kldscs[at]gmail.com>
 * @copyright Copyleft (D.) 2007 - 2010 LD pr.
 * @link 
 * @example 
 *   
 */
class Zcredit{

    /***
     * 求淘宝卖家的信用等级图标
     * 
     * 红心: http://pics.taobaocdn.com/newrank/s_red_1.gif
     * 砖石: http://pics.taobaocdn.com/newrank/s_blue_5.gif
     * 皇冠: http://pics.taobaocdn.com/newrank/s_cap_3.gif
     * 金冠: http://pics.taobaocdn.com/newrank/s_crown_3.gif 
     *
     */
    public static function taobao_credit_ico( $level=null){
        $level = (int)$level;
        if( 1>$level ) return null;
        
        $ico = 'http://pics.taobaocdn.com/newrank/s_';
        if($level < 6){
            $num = $level;
            $ico .= 'red';
        
        }else if($level < 11){
            $num = $level-5;
            $ico .= 'blue';

        }else if($level < 16){
            $num = $level-10;
            $ico .= 'cap';

        }else{
            $num = (20<$level) ? 5 : ($level-15);
            $ico .= 'crown';
        }
        
        $ico .= '_'.$num.'.gif';
        return $ico;
    }

    /**
     * 根据分数，得出结果
     *
     */
    public static function taobao_score_star($score=4){
        $offset = 16;
        $score = (5<$score) ? 0 : 5-$score;
        $result = 0;
        if(0<$score){
            $result = floor($score/0.5);
            $score = $score - $result*0.5;
            $result += floor($score);
            $result = $offset*$result;
        }
        
        return (0<$result) ? -$result: 0;
    }


    //获取卖家信用等级图标
    public static function taobao_seller_medal($sorce){  //[getSellerMedal]
        if($sorce<4){
            return null;
        }
        if($sorce<=10){
            $ico = 's_red_1.gif';
        }elseif($sorce <= 40){
            $ico = 's_red_2.gif';
        }elseif($sorce <= 90){
            $ico = 's_red_3.gif';
        }elseif($sorce <= 150){
            $ico = 's_red_4.gif';
        }elseif($sorce <=250){
            $ico = 's_red_5.gif';
        }
        elseif($sorce <= 500){
            $ico = 's_blue_1.gif';
        }elseif($sorce <= 1000){
            $ico = 's_blue_2.gif';
        }elseif($sorce <= 2000){
            $ico = 's_blue_3.gif';
        }elseif($sorce <= 5000){
            $ico = 's_blue_4.gif';
        }elseif($sorce <= 10000){
            $ico = 's_blue_5.gif';
        }
        elseif($sorce <= 20000){
            $ico = 's_cap_1.gif';
        }elseif($sorce <= 50000){
            $ico = 's_cap_2.gif';
        }elseif($sorce <= 100000){
            $ico = 's_cap_3.gif';
        }elseif($sorce <= 200000){
            $ico = 's_cap_4.gif';
        }elseif($sorce <=500000){
            $ico = 's_cap_5.gif';
        }
        elseif($sorce <= 1000000){
            $ico = 's_crown_1.gif';
        }elseif($sorce <= 2000000){
            $ico = 's_crown_2.gif';
        }elseif($sorce <= 5000000){
            $ico = 's_crown_3.gif';
        }elseif($sorce <= 10000000){
            $ico = 's_crown_4.gif';
        }elseif($sorce > 10000000){
            $ico = 's_crown_5.gif';
        }
        return 'http://pics.taobaocdn.com/newrank/'.$ico;
    }//END func taobao_seller_medal

    //获取买家信用等级图标
    public static function taobao_buyer_medal($sorce){  //[getBuysMedal]
        $ico = '';
        if($sorce > 4 && $sorce <= 250){
            if($sorce <= 10){
                $ico = 'http://pics.taobaocdn.com/newrank/b_red_1.gif';
            }elseif($sorce > 10 && $sorce <= 40){
                $ico = 'http://pics.taobaocdn.com/newrank/b_red_2.gif';
            }elseif($sorce > 40 && $sorce <= 90){
                $ico = 'http://pics.taobaocdn.com/newrank/b_red_3.gif';
            }elseif($sorce > 90 && $sorce <= 150){
                $ico = 'http://pics.taobaocdn.com/newrank/b_red_4.gif';
            }elseif($sorce > 150){
                $ico = 'http://pics.taobaocdn.com/newrank/b_red_5.gif';
            }
        }elseif($sorce > 250 && $sorce <= 10000){
            if($sorce <= 500){
                $ico = 'http://pics.taobaocdn.com/newrank/b_blue_1.gif';
            }elseif($sorce > 500 && $sorce <= 1000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_blue_2.gif';
            }elseif($sorce > 1000 && $sorce <= 2000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_blue_3.gif';
            }elseif($sorce > 2000 && $sorce <= 5000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_blue_4.gif';
            }elseif($sorce > 5000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_blue_5.gif';
            }
        }elseif($sorce > 10000 && $sorce <= 500000){
            if($sorce <= 20000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_cap_1.gif';
            }elseif($sorce > 20000 && $sorce <= 50000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_cap_2.gif';
            }elseif($sorce > 50000 && $sorce <= 100000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_cap_3.gif';
            }elseif($sorce > 100000 && $sorce <= 200000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_cap_4.gif';
            }elseif($sorce > 200000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_cap_5.gif';
            }
        }elseif($sorce > 500000){
            if($sorce <= 1000000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_crown_1.gif';
            }elseif($sorce > 1000000 && $sorce <= 2000000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_crown_2.gif';
            }elseif($sorce > 2000000 && $sorce <= 5000000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_crown_3.gif';
            }elseif($sorce > 5000000 && $sorce <= 10000000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_crown_4.gif';
            }elseif($sorce > 10000000){
                $ico = 'http://pics.taobaocdn.com/newrank/b_crown_5.gif';
            }
        }
        return $ico;
    }//END func taobao_buyer_medal


}//END class


